package com.rdxer.service;

import com.rdxer.core.utils.IdWorker;
import com.rdxer.dataview.PaperQuestionDV;
import com.rdxer.model.Clazz;
import com.rdxer.model.ClazzStudentRelation;
import com.rdxer.model.Course;
import com.rdxer.model.Paper;
import com.rdxer.repository.ClazzRepository;
import com.rdxer.repository.CourseRepository;
import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Department 服务层
 */
@Service
@Data
@Getter
public class CourseService implements CRUDPageServiceInterface<Course, String>  {


    @Autowired
    private CourseRepository repository;

    @Autowired
    private IdWorker idWorker;

    @Autowired
    ClazzStudentRelationService clazzStudentRelationService;
    @Autowired
    PaperService paperService;
    public List<Course> findAllByUserId(String userId) {
        ClazzStudentRelation byUserId = clazzStudentRelationService.findByUserId(userId);
        String clazzId = byUserId.getClazzId();
        List<Course> allByClazzId = repository.findAllByClazzId(clazzId);
        return allByClazzId;
    }


    public List<Paper> findAllPaperByCourseId(String courseId) {
        return paperService.findAllByCourseId(courseId);
    }
}
